<include file="nav:header"/>
<div class="container-fluid">
    <div class="row">
        <script type="text/javascript">
            function _icont(obj,id) {
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-lan',
                        title: ['ئايكون قوشۇش', 'background:#1E9FFF;text-align: center'],
                        fix: false,
                        shadeClose: true,
                        maxmin: true,
                        area: ['20%', '40%'],
                        content: "{:U('Menu/icon')}?id="+$(obj).attr('title')
//                    end: function () {           //关闭弹出层触发
//                        location.href="{:U('Menu/icon')}"+
//                    }
                    })
            }
        </script>
        <include file="Left:left-Common"/>
        <!-- right -->

        <div class="col-md-10 right">
            <!--<p onclick="_icont(this)" class="id" title="26">pppppppppppppppp</p>-->
            <div class="page-header" style="margin-right: 15px">
                <h3>{$page_title}</h3>
            </div>
            <div class="col-md-12">
                <div class="index_top">
                    <div style="margin-left: 50px" class="btn-group pull-left " role="group" aria-label="Large button group">
                        <a href="{:U('Menu/index')}" type="button" class="btn btn-default">بارلىق تىزىملىك</a>
                        <a href="{:U('Menu/add')}" type="button" class="btn btn-default">تىزىملىك قوشۇش</a>
                    </div>
                    <div class="col-md-2 pull-left"></div>
                    <select onchange="serach(this.value) ;"  class="form-control input-sm serach pull-right" style="width: 20%;font-size: 15px;line-height: 34px;height: 34px">
                        <option <if condition="$get_id eq 0">selected</if>  value="0">بارلىق</option>
                        <foreach name="classify" item="c">
                            <option <if condition="$c.id eq $get_id">selected</if>  value="{$c.id}">{$c['name']}</option>
                        </foreach>
                    </select>
                </div>
                <!--所有分类-->
                <br><br>
                <table class="table table-bordered">
                    <thead>
                    <tr class="info">
                        <th width="50">CID</th>
                        <th>تىزىملىك نامى</th>
                        <th style="text-align: center">图标</th>
                        <th width="60">تەرتىبى </th>
                        <th style="text-align: center" width="170">ئۇلانما ئادېرىسى </th>
                        <th style="text-align: center">ھالىتى</th>
                        <th style="text-align: center" >قوشۇلغان ۋاقىت </th>
                        <th style="text-align: center">ئۆزگەرتكەن ۋاقىت</th>
                        <th style="text-align: center">مەشغۇلات</th>
                    </tr>
                    </thead>
                    <tbody>
                        <foreach name="menu" item="c">
                            <tr class="classifys active">
                                <td>{$c['id']}</td>
                                <td style="font-size: 15px">
                                    <if condition="$c['lavel'] neq 0">{$c.lavel|_repeat}┘─</if>
                                    &nbsp;{$c.name}
                                </td>
                                <td style="text-align: center">
                                    <if condition="$c.icon neq no"><img width="40px" src="/{$c.icon|_strpos}" />
                                    <else/>
                                        <a title="{$c.id}" style="font-size: 11px;color: rgba(0,0,255,0.67)" onclick="_icont(this,{$c.id})" href="javascript:;">ئايكون يوللاش</a>
                                    </if>
                                </td>
                                <td><input onchange="_sort(this,{$c['id']})" class="form-control <if condition="$c['pid'] eq 0" >fonszie</if>" type="text" value="{$c['sort']}" ></td>
                                <td><input onchange="_url(this,{$c['id']})" class="form-control" type="text" value="{$c['url']}" style="font-size: 13px;direction: ltr" ></td>
                                <td style="text-align: center">
                                    <if condition="$c['status'] eq 1">
                                        <span style="margin-top: 6px;display: inline-block;"  onclick="_status(this,0,{$c['id']})"  class="btn btn-success btn-xs kaiguan">ئوچۇق</span>
                                        <else/>
                                        <span style="margin-top: 6px;display: inline-block;" onclick="_status(this,1,{$c['id']})" class="btn btn-danger btn-xs kaiguan">تاقاق</span>
                                    </if>
                                </td>
                                <td style="text-align: center;direction: ltr">{$c.intime}</td>
                                <td style="text-align: center;direction: ltr">{$c.uptime}</td>
                                <td style="text-align: center">
                                    <a  style="margin-top: 6px;display: inline-block;" href="{:U('Menu/edit',array('id'=>$c['id']))}" class="btn btn-success btn-xs ">تەھرىرلەش</a>
                                    <a  style="margin-top: 6px;display: inline-block;" href="javascript:del({$c['id']});" class="btn btn-danger btn-xs">ئۆچۈرۈش</a>
                                </td>
                            </tr>
                        </foreach>
                    </tbody>
                </table>
                <if condition="$count gt  $meige">
                    <div class="page_ye">
                        <dl>
                            <dd>جەمئى {$count} تال ئۇچۇر بار</dd>
                        </dl>
                        <!--分页-->
                        {$page}
                        <div style="clear:both;height: 2px;"></div>
                    </div>
                </if>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function serach(val) {
        window.location.href="{:U('Menu/index')}?id="+val;
    }
    //链接地址
    function _url(obj,id) {
        var url=$(obj).val();
        $.ajax({
            type:"post",
            url:"{:U('Menu/url')}",
            dataType:"json",
            data:{"url":url,"id":id},
            success:function (phpdata) {
                if(phpdata.status==1){
                    layer.alert(phpdata.message, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 6,
                        skin: 'layer-ext-moon',
                        time:800
                    });
                    window.location=location;
                }else{
                    layer.alert(phpdata.message, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 5,
                        skin: 'layer-ext-moon',
                        time:1000
                    });
                }
            }
        })
    }
    //分类排序
    function _sort(obj,id) {
        var val=$(obj).val();
        $.ajax({
            type:"post",
            url:"{:U('Menu/sortfen')}",
            dataType:"json",
            data:{"sort":val,"id":id},
            success:function (phpdata) {
                if(phpdata.status==1){
                    layer.alert(phpdata.message, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 6,
                        skin: 'layer-ext-moon',
                        time:800
                    });
                    window.location=location;
                }else{
                    layer.alert(phpdata.message, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 5,
                        skin: 'layer-ext-moon',
                        time:1000
                    });
                }
            }
        })
    }
    //删除分类
    function del(id) {
        layer.confirm('بۇ ئۇچۇرنى راستىنلا ئۆچۈرەمسىز ؟', {
            title:"سېستىما ئەسكەرتىشى",
            btn: ['ھەئە','ياق'] //按钮
        }, function(){
            $.ajax({
                type:"post",
                url:"{:U('Menu/del')}",
                dataType:"json",
                data:{"id":id},
                success:function (phpdata) {
                    if(phpdata.status==1){
                        layer.alert(phpdata.message, {
                            title:"سېستىما ئەسكەرتىشى",
                            btn:"بىلدىم",
                            icon: 6,
                            skin: 'layer-ext-moon',
                            time:800
                        });
                        window.location=location;
                    }else{
                        layer.alert(phpdata.message, {
                            title:"سېستىما ئەسكەرتىشى",
                            btn:"بىلدىم",
                            icon: 5,
                            skin: 'layer-ext-moon',
                            time:1000
                        });
                    }
                }
            })
        });

    }
    //分类状态
    function _status(obj,status,id) {
        if(status=='0'){
            $(obj).removeClass("btn-success");
            $(obj).addClass("btn-danger");
            $(obj).text("تاقاق")
        }else {
            $(obj).removeClass("btn-danger");
            $(obj).addClass("btn-success");
            $(obj).text("ئوچۇق")
        }
        $.ajax({
            type:"post",
            url:"{:U('Menu/sortStatus')}",
            dataType:"json",
            data:{"id":id,"status":status},
            success:function (phpdata) {
                if(phpdata.status==1){
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 6,
                        skin: 'layer-ext-moon',
                        time:400
                    });
                    window.location=location;
                }else{
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 5,
                        skin: 'layer-ext-moon',
                        time:1000
                    });
                }
            }
        })
    }
    $(function () {
        $('.classifys').hover(function () {
            $(this).addClass('info');
        },function () {
            $(".classifys").removeClass('info');
        })
    })
</script>
<include file="nav:footer"/>